package com.mt.operation.service.model;

import java.util.List;
import java.util.Map;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import com.github.pagehelper.PageHelper;
import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.operation.entity.HomePageOperationCategoryEntity;
import com.mt.operation.mapper.HomePageOperationCategoryEntityMapper;

@Component
public class HomePageOperationCategoryServiceModel {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(NewComerPackageLogServiceModel.class);

    @Autowired
    private HomePageOperationCategoryEntityMapper homePageOperationCategoryEntityMapper;



    public ServiceResult<List<HomePageOperationCategoryEntity>> selectList(Map<String, Object> params,
            PagerInfo<?> pagerInfo) {
        Assert.notNull(this.homePageOperationCategoryEntityMapper, "Property 'customerPopupEntityMapper' is required.");
        ServiceResult<List<HomePageOperationCategoryEntity>>
            result = new ServiceResult<List<HomePageOperationCategoryEntity>>();
        try {
            if (pagerInfo != null) {
                PageHelper.startPage(pagerInfo.getPageIndex(), pagerInfo.getPageSize());
            }
            result.setResult(this.homePageOperationCategoryEntityMapper.selectList(params));
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[HomePageOperationCategoryServiceModel][selectList]：query selectList occur exception", e);
        }
        return result;
    }

    public ServiceResult<HomePageOperationCategoryEntity> selectInfo(Map<String, Object> params) {
        Assert.notNull(this.homePageOperationCategoryEntityMapper, "Property 'customerPopupEntityMapper' is required.");
        ServiceResult<HomePageOperationCategoryEntity> result = new ServiceResult<HomePageOperationCategoryEntity>();
        try {
            result.setResult(this.homePageOperationCategoryEntityMapper.selectByPrimaryKey(params));
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[HomePageOperationCategoryServiceModel][selectInfo]：query selectInfo occur exception", e);
        }
        return result;
    }

    public ServiceResult<Integer> insert(HomePageOperationCategoryEntity homePageOperationCategoryEntity) {
        Assert.notNull(this.homePageOperationCategoryEntityMapper,
                "Property 'newComerPackageLogEntityMapper' is required.");
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            int save = this.homePageOperationCategoryEntityMapper.insert(homePageOperationCategoryEntity);
            result.setResult(save);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[HomePageOperationCategoryServiceModel][insert]：query insert occur exception", e);
        }
        return result;
    }

    public ServiceResult<Integer> updateByPrimaryKeySelective(
            HomePageOperationCategoryEntity homePageOperationCategoryEntity) {
        Assert.notNull(this.homePageOperationCategoryEntityMapper,
                "Property 'operationSiteLogEntityMapper' is required.");
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            int save = this.homePageOperationCategoryEntityMapper
                    .updateByPrimaryKeySelective(homePageOperationCategoryEntity);
            result.setResult(save);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error(
                    "[HomePageOperationCategoryServiceModel][updateByPrimaryKeySelective]:query update occur exception",
                    e);
        }
        return result;
    }

    public ServiceResult<Integer> deleteByPrimaryKey(Integer homePageOperationCategoryId) {
        Assert.notNull(this.homePageOperationCategoryEntityMapper,
                "Property 'newComerPackageLogEntityMapper' is required.");
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        int save = 0;
        try {
            save = this.homePageOperationCategoryEntityMapper.deleteByPrimaryKey(homePageOperationCategoryId);
            result.setResult(save);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[HomePageOperationCategoryServiceModel][deleteByPrimaryKey]:query update occur exception", e);
        }
        return result;
    }

}
